<template>
    <h1>我是 APP 组件</h1>

    <button @click="flag = true">打开遮罩层</button>

    <Teleport to="body">
        <div v-if="flag" class="box">
            <div class="msg">
                <p class="title">弹出框</p>
                <p class="showmsg">请问您确定删除吗?</p>
                <div>
                    <button @click="flag = false">取消</button>
                    <button @click="flag = false">确定</button>
                </div>
            </div>
        </div>
    </Teleport>
</template>

<script>
export default {
    data() {
        return {
            flag: false,
        };
    },
};
</script>

<style>
* {
    padding: 0;
    margin: 0;
}
html,
body,
#app {
    width: 100%;
    height: 100%;
}

.box {
    background-color: rgba(0, 0, 0, 0.3);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.box .msg {
    background-color: white;
    width: 300px;
    height: 100px;
    border-radius: 10px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
}
</style>
